package com.juc.forkJoin.forkJoin5;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;

public class Test {

	//任务之间是异步的 但join()方法同步的
	public static void main(String[] args) throws InterruptedException {
		ForkJoinPool pool = new ForkJoinPool();
		ForkJoinTask<Integer> runTaskA = pool.submit(new MyRecursiveTaskA());
		ForkJoinTask<Integer> runTaskB = pool.submit(new MyRecursiveTaskB());
	    System.out.println("准备打印 === " + System.currentTimeMillis());
	    System.out.println(runTaskA.join() + " A : " +System.currentTimeMillis());
	    System.out.println(runTaskB.join() + " B : " +System.currentTimeMillis());

	    Thread.sleep(5000);
	}
}
